<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>认证审核</title>

  {include file='common/_require'/}
</head>

<body>

  {include file='common/_header'/}

  <div class="layui-container fly-marginTop fly-user-main">
    {include file='common/_user'/}
    <script>$('.user-nav-item-post-status').addClass('layui-this')</script>


    <div class="fly-panel fly-panel-user" pad20>
      <div class="layui-tab layui-tab-brief" lay-filter="user">
        <ul class="layui-tab-title status-manage">
          <li class="status-2" data-href="{:url('statusManage',['is_verify'=>2])}">审核中</li>
          <li class="status-0" data-href="{:url('statusManage',['is_verify'=>0])}">下架</li>
          <li class="status-1" data-href="{:url('statusManage',['is_verify'=>1])}">通过</li>

        </ul>
        <script>$('.status-{$Request.param.is_verify}').addClass('layui-this')</script>
        <div class="layui-tab-content" style="padding: 20px 0;">
          <div class="layui-form layui-form-pane layui-tab-item layui-show">

            <table class="layui-table">
              <thead>
                <tr>
                  <th>文章ID</th>
                  <th>标题</th>
                  <th>封面</th>
                  <th>简介</th>
                  <th>排序</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                {volist name='list_post' id='post'}

                <tr class="item" data-id="{$post.id}">
                  <td>{$post.id}</td>
                  <td>
                    <a href="{$post.read_url}" target="_blank">{$post.title}</a>
                  </td>
                  <td>
                    <img src="{$post.title_img_src}" alt="">
                  </td>

                  <td>{:\\app\\common\\TextFormat::br($post.desc)}</td>
                  <td>
                    <span>{$post.sort}</span>
                    <i class="layui-icon layui-icon-edit edit-sort" style="cursor: pointer;"></i>
                  </td>
                  <td>
                    <div>
                      {in name='Request.param.is_verify' value='0,2' }
                      <div class="layui-btn layui-btn-sm pass">通过</div>
                      {/in}
                      {in name='Request.param.is_verify' value='1,2' }
                      <div class="layui-btn layui-btn-sm refuse">下架</div>
                      {/in}

                    </div>
                  </td>
                </tr>
                {/volist}
                {empty name='$list_post'}
                <tr>
                  <td colspan="6">暂无数据</td>
                </tr>
                {/empty}
              </tbody>
            </table>

          </div>

        </div>

      </div>
    </div>
  </div>
  </div>
  {include file='common/_footer'/}

  <script>

    layui.use(['form', 'upload'], function () {

      $('.status-manage li').click(function () {
        var item = this;

        var data = $(item).data();

        location.href = data.href
      })
      $('.pass').click(function () {
        var item = this;
        layer.prompt({
          title: '向用户发送消息',
          formType: 2,
          value: '您的文章已通过'
        }, function (value, index) {

          $.post('{:url("updateStatus")}', {
            id: $(item).parents('.item').data('id'),
            is_verify: 1,
          }, function (result) {
            if (result.code == 0) {
              layer.msg('设置成功')
              layer.close(index)
              setTimeout(() => {
                location.reload();
              }, 1200);
            } else {
              layer.msg(result.msg)
            }
          })
        })
      })
      $('.refuse').click(function () {
        var item = this;
        layer.prompt({
          title: '向用户发送消息',
          formType: 2,
          value: '您的文章已被下架'
        }, function (value, index) {

          $.post('{:url("updateStatus")}', {
            id: $(item).parents('.item').data('id'),
            is_verify: 0,
          }, function (result) {
            if (result.code == 0) {
              layer.msg('设置成功')
              layer.close(index)
              setTimeout(() => {
                location.reload();
              }, 1200);
            } else {
              layer.msg(result.msg)
            }
          })
        })
      })

      $('.edit-sort').click(function(){
        var item = this;
        layer.prompt({
          title: '修改排序(越大越靠前)',
          formType: 0,
          value: $(item).siblings('span').text()
        }, function (value, index) {

          $.post('{:url("updateStatus")}', {
            id: $(item).parents('.item').data('id'),
            sort: value,
          }, function (result) {
            if (result.code == 0) {
              layer.msg('设置成功')
              layer.close(index)
              setTimeout(() => {
                location.reload();
              }, 1200);
            } else {
              layer.msg(result.msg)
            }
          })
        })
      })
    })

  </script>
</body>

</html>